package cn.client.ui.view

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavController
import cn.client.MainViewModel
import cn.client.R
import cn.client.navigation.destinations.AppStart
import cn.client.navigation.destinations.Overview
import cn.client.navigation.destinations.SignInHost
import cn.client.navigation.destinations.SignInSecond
import cn.client.navigation.destinations.SignUpHost
import cn.client.ui.view.signIn.SignInViewModel
import kotlinx.coroutines.launch

@Composable
fun AppScreen(
    navController: NavController
) {
    Column(
        modifier = Modifier
            .fillMaxWidth()
            .fillMaxHeight()
            .background(Color.White)
    ){
        /* 间隔距离 */
        Spacer(modifier = Modifier.height(150.dp))
        /* 标题 */
        Row(
            modifier = Modifier
                .fillMaxWidth()
                .padding(10.dp)
        ) {
            Text(
                text = (stringResource(R.string.welcome)),
                textAlign = TextAlign.Center,
                fontSize = 30.sp, // 字体大小
                fontWeight = FontWeight.Bold,
                color = Color.DarkGray
            )
        }
        /* 间隔距离 */
        Spacer(modifier = Modifier.height(10.dp))
        /* 副标题 */
        Row(
            modifier = Modifier
                .fillMaxWidth()
                .padding(10.dp)
        ) {
            Text(
                text = (stringResource(R.string.welcome_info)),
                textAlign = TextAlign.Center,
                fontSize = 16.sp, // 字体大小
                color = Color.Gray
            )
        }
        /* 间隔距离 */
        Spacer(modifier = Modifier.height(10.dp))
        /* 登录按钮 */
        Row(
            modifier = Modifier
                .fillMaxWidth()
                .padding(10.dp)
        ) {
            Button(
                modifier = Modifier.fillMaxWidth(),
                onClick = {
                    /*跳转登录页面*/
                    navController.navigate(SignInHost.route)
                }
            ) {
                Text(
                    text = (stringResource(R.string.sign_in)),
                    textAlign = TextAlign.Center
                )
            }
        }
        /* 间隔距离 */
        Spacer(modifier = Modifier.height(10.dp))
        /* 注册按钮 */
        Row(
            modifier = Modifier
                .fillMaxWidth()
                .padding(10.dp)
        ) {
            Button(
                modifier = Modifier.fillMaxWidth(),
                onClick = {
                    /*跳转注册页面*/
                    navController.navigate(SignUpHost.route)
                }
            ) {
                Text(
                    text = (stringResource(R.string.sign_up)),
                    textAlign = TextAlign.Center
                )
            }
        }
    }
}